﻿using System;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x0200005E RID: 94
	[AddComponentMenu("Scripts/RootMotion.FinalIK/Interaction System/Interaction Target")]
	[HelpURL("https://www.youtube.com/watch?v=r5jiZnsDH3M")]
	public class InteractionTarget : MonoBehaviour
	{
		// Token: 0x0600042E RID: 1070 RVA: 0x0000490A File Offset: 0x00002B0A
		[ContextMenu("TUTORIAL VIDEO (PART 1: BASICS)")]
		public void OpenTutorial1()
		{
			Application.OpenURL("https://www.youtube.com/watch?v=r5jiZnsDH3M");
		}

		// Token: 0x0600042F RID: 1071 RVA: 0x00004916 File Offset: 0x00002B16
		[ContextMenu("TUTORIAL VIDEO (PART 2: PICKING UP...)")]
		public void OpenTutorial2()
		{
			Application.OpenURL("https://www.youtube.com/watch?v=eP9-zycoHLk");
		}

		// Token: 0x06000430 RID: 1072 RVA: 0x00004922 File Offset: 0x00002B22
		[ContextMenu("TUTORIAL VIDEO (PART 3: ANIMATION)")]
		public void OpenTutorial3()
		{
			Application.OpenURL("https://www.youtube.com/watch?v=sQfB2RcT1T4&index=14&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6");
		}

		// Token: 0x06000431 RID: 1073 RVA: 0x0000492E File Offset: 0x00002B2E
		[ContextMenu("TUTORIAL VIDEO (PART 4: TRIGGERS)")]
		public void OpenTutorial4()
		{
			Application.OpenURL("https://www.youtube.com/watch?v=-TDZpNjt2mk&index=15&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6");
		}

		// Token: 0x06000432 RID: 1074 RVA: 0x00002E24 File Offset: 0x00001024
		[ContextMenu("Support Group")]
		public void SupportGroup()
		{
			Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik");
		}

		// Token: 0x06000433 RID: 1075 RVA: 0x00002E30 File Offset: 0x00001030
		[ContextMenu("Asset Store Thread")]
		public void ASThread()
		{
			Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/");
		}

		// Token: 0x06000434 RID: 1076 RVA: 0x0002F29C File Offset: 0x0002D49C
		public float GetValue(InteractionObject.WeightCurve.Type curveType)
		{
			for (int i = 0; i < this.multipliers.Length; i++)
			{
				if (this.multipliers[i].curve == curveType)
				{
					return this.multipliers[i].multiplier;
				}
			}
			return 1f;
		}

		// Token: 0x06000435 RID: 1077 RVA: 0x00004AD2 File Offset: 0x00002CD2
		public void ResetRotation()
		{
			if (this.pivot != null)
			{
				this.pivot.localRotation = this.defaultLocalRotation;
			}
		}

		// Token: 0x06000436 RID: 1078 RVA: 0x0002F2E8 File Offset: 0x0002D4E8
		public void RotateTo(Vector3 position)
		{
			if (this.pivot == null)
			{
				return;
			}
			if (this.pivot != this.lastPivot)
			{
				this.defaultLocalRotation = this.pivot.localRotation;
				this.lastPivot = this.pivot;
			}
			this.pivot.localRotation = this.defaultLocalRotation;
			if (this.twistWeight > 0f)
			{
				Vector3 fromDirection = base.transform.position - this.pivot.position;
				Vector3 vector = this.pivot.rotation * this.twistAxis;
				Vector3 vector2 = vector;
				Vector3.OrthoNormalize(ref vector2, ref fromDirection);
				vector2 = vector;
				Vector3 toDirection = position - this.pivot.position;
				Vector3.OrthoNormalize(ref vector2, ref toDirection);
				Quaternion b = QuaTools.FromToAroundAxis(fromDirection, toDirection, vector);
				this.pivot.rotation = Quaternion.Lerp(Quaternion.identity, b, this.twistWeight) * this.pivot.rotation;
			}
			if (this.swingWeight > 0f)
			{
				Quaternion b2 = Quaternion.FromToRotation(base.transform.position - this.pivot.position, position - this.pivot.position);
				this.pivot.rotation = Quaternion.Lerp(Quaternion.identity, b2, this.swingWeight) * this.pivot.rotation;
			}
		}

		// Token: 0x06000437 RID: 1079 RVA: 0x000049B5 File Offset: 0x00002BB5
		[ContextMenu("User Manual")]
		public void OpenUserManual()
		{
			Application.OpenURL("http://www.root-motion.com/finalikdox/html/page10.html");
		}

		// Token: 0x06000438 RID: 1080 RVA: 0x00004AF6 File Offset: 0x00002CF6
		[ContextMenu("Scrpt Reference")]
		public void OpenScriptReference()
		{
			Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_interaction_target.html");
		}

		// Token: 0x040002C9 RID: 713
		[Tooltip("The type of the FBBIK effector.")]
		public FullBodyBipedEffector effectorType;

		// Token: 0x040002CA RID: 714
		[Tooltip("InteractionObject weight curve multipliers for this effector target.")]
		public InteractionTarget.Multiplier[] multipliers;

		// Token: 0x040002CB RID: 715
		[Tooltip("The interaction speed multiplier for this effector. This can be used to make interactions faster/slower for specific effectors.")]
		public float interactionSpeedMlp = 1f;

		// Token: 0x040002CC RID: 716
		[Tooltip("The pivot to twist/swing this interaction target about. For symmetric objects that can be interacted with from a certain angular range.")]
		public Transform pivot;

		// Token: 0x040002CD RID: 717
		[Tooltip("The axis of twisting the interaction target (blue line).")]
		public Vector3 twistAxis = Vector3.up;

		// Token: 0x040002CE RID: 718
		[Tooltip("The weight of twisting the interaction target towards the effector bone in the start of the interaction.")]
		public float twistWeight = 1f;

		// Token: 0x040002CF RID: 719
		[Tooltip("The weight of swinging the interaction target towards the effector bone in the start of the interaction. Swing is defined as a 3-DOF rotation around any axis, while twist is only around the twist axis.")]
		public float swingWeight;

		// Token: 0x040002D0 RID: 720
		[Tooltip("If true, will twist/swing around the pivot only once at the start of the interaction. If false, will continue rotating throuout the whole interaction.")]
		public bool rotateOnce = true;

		// Token: 0x040002D1 RID: 721
		public Quaternion defaultLocalRotation;

		// Token: 0x040002D2 RID: 722
		public Transform lastPivot;

		// Token: 0x0200005F RID: 95
		[Serializable]
		public class Multiplier
		{
			// Token: 0x040002D3 RID: 723
			[Tooltip("The curve type (InteractionObject.WeightCurve.Type).")]
			public InteractionObject.WeightCurve.Type curve;

			// Token: 0x040002D4 RID: 724
			[Tooltip("Multiplier of the curve's value.")]
			public float multiplier;
		}
	}
}
